package com.awspaas.user.apps.publicservice.util;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.sdk.local.SDK;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author:Lizj
 * @create: 2022-09-28 23:48
 * @Description: 更新业务待办状态
 */
public class BusinessEventUtil {

    /**
     * @methodName:
     * @param:
     * @return:
     * @description:更新统一业务待办表对应记录业务待办状态
     * @auther: Lizj
     * @date: 2022/9/28 23:56
     */
    public static void updateBusinessStatus(String taskId) {
        BO businessTodoBo = SDK.getBOAPI().query("BO_PS_BUSINESS_TODO_INTEGRATE", true).addQuery("TASKID =", taskId).detail();
        if (null!=businessTodoBo) {
            String bindid = businessTodoBo.getString("BINDID");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            //业务待办状态
            String businesstaskstatus = businessTodoBo.getString("BUSINESSTASKSTATUS");
            //当前业务待办状态为空或未办理
            if (null==businesstaskstatus || businesstaskstatus.equals("") || businesstaskstatus.equals("01")) {
                businessTodoBo.set("BINDID", bindid);
                businessTodoBo.set("BUSINESSTASKSTATUS", "02");
                String nowDateFormat = sdf.format(new Date(System.currentTimeMillis()));
                businessTodoBo.set("BUSINESSTASKENDTIME", nowDateFormat);
                SDK.getBOAPI().updateByBindId("BO_PS_BUSINESS_TODO_INTEGRATE", businessTodoBo);
            } else {
            //当前业务待办状态为已办理
                businessTodoBo.set("BINDID", bindid);
                businessTodoBo.set("BUSINESSTASKSTATUS", "02");
                String nowDateFormat = sdf.format(new Date(System.currentTimeMillis()));
                businessTodoBo.set("BUSINESSTASKENDTIME", nowDateFormat);
                businessTodoBo.set("BUSINESSREMARKS", "当前业务待办已为已办理状态");
                SDK.getBOAPI().updateByBindId("BO_PS_BUSINESS_TODO_INTEGRATE", businessTodoBo);
            }
        }
    }
}
